import router from '@/router';
import store from '@/store';
import { request } from '@/utils';

// 获取活动详情
export const init = (id) => {
  return request({
    url: `/activity/base/info/${id}`,
    method: 'get',
  });
};

// 初始化
export const initData = async (id, path) => {
  init(id)
    .then(({ data }) => {
      store.dispatch('setInitData', data);
      if (path) {
        router.push(path);
      }
    })
    .catch((error) => {
      console.log(error);
    });
};
